package com.banciyuan.bcywebview.biz.search;

import android.view.View;

import com.banciyuan.bcywebview.R;
import com.banciyuan.bcywebview.base.fragment.BaseLazyContainerFragment;
import com.banciyuan.bcywebview.base.helper.ProgressbarHelper;

/**
 * Created by squall on 2017/6/20.
 */

public class SearchBaseFragment extends BaseLazyContainerFragment {

    protected String query;
    protected ProgressbarHelper mProgressbarHelper;
    protected View mProgressbarView;
    protected int page = 1;
    protected boolean end_flag = false;
    protected boolean loading = false;

    public void setQuery(String query) {
        this.query = query;
    }

    @Override
    protected void initProgressbar(View rootview) {
        mProgressbarView = rootview.findViewById(R.id.base_progressbar);
        mProgressbarHelper = new ProgressbarHelper(mProgressbarView);
        mProgressbarHelper.setActionCallbacks(new ProgressbarHelper.OnProgressCallbacks() {
            @Override
            public void onActionClick(int id) {
                mProgressbarHelper.onLoading();
                page = 1;
                initData();
            }
        });
        mProgressbarHelper.onLoading();
    }

    public void reset() {
        mProgressbarHelper.onLoading();
        loading = false;
        end_flag = false;
        page = 1;
        initData();
    }

    public void resetLoading() {
        mProgressbarHelper.onLoading();
    }
}
